package texas_holdem.data;

public class Card {
	public enum  CardNumber{ Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King};
	public enum  CardType{ Diamond, Heart, Club, Spade};
	
	
	private final CardNumber _num;
	private final CardType _type;
	private String _name;
	
	public Card(CardNumber num, CardType type)
	{
		_num = num;
		_type = type;
		_name = toString();
	}
	
	public String getName()
	{
		return _name;
	}
	public CardNumber getNumber()
	{
		return _num;
	}
	public CardType getType()
	{
		return _type;
	}
	
	public String getId()
	{
		String res = "";
		switch (_type)
		{
			case Diamond:
				res+= "d";
				break;
			case Heart:
				res+= "h";
				break;
			case Club:
				res+= "c";
				break;
			case Spade:
				res+= "s";
				break;
		}
		switch(_num)
		{
			case Ace:
				res+= "1";
				break;
			case Two:
				res+= "2";
				break;
			case Three:
				res+= "3";
				break;
			case Four:
				res+= "4";
				break;
			case Five:
				res+= "5";
				break;
			case Six:
				res+= "6";
				break;
			case Seven:
				res+= "7";
				break;
			case Eight:
				res+= "8";
				break;
			case Nine:
				res+= "9";
				break;
			case Ten:
				res+= "t";
				break;
			case Jack:
				res+= "j";
				break;
			case Queen:
				res+= "q";
				break;
			case King:
				res+= "k";
				break;
		}
	
		return res;	
	}
	
	public String toString()
	{
		String res = "";
		switch(_num)
		{
			case Ace:
				res+= "1 ";
				break;
			case Two:
				res+= "2 ";
				break;
			case Three:
				res+= "3 ";
				break;
			case Four:
				res+= "4 ";
				break;
			case Five:
				res+= "5 ";
				break;
			case Six:
				res+= "6 ";
				break;
			case Seven:
				res+= "7 ";
				break;
			case Eight:
				res+= "8 ";
				break;
			case Nine:
				res+= "9 ";
				break;
			case Ten:
				res+= "T ";
				break;
			case Jack:
				res+= "J ";
				break;
			case Queen:
				res+= "Q ";
				break;
			case King:
				res+= "K ";
				break;
		}
		switch (_type)
		{
			case Diamond:
				res+= "d ";
				break;
			case Heart:
				res+= "h ";
				break;
			case Club:
				res+= "c ";
				break;
			case Spade:
				res+= "s ";
				break;
		}
		return res;
	}
	
	public boolean equals(Object o)
	{
		Card c = (Card) o;
		return c.getNumber().equals(_num) && c.getType().equals(_type);
	}
}
